$(document).ready(function() {
	$.active = false;
	$('body').bind('click keypress', function() {
		$.active = true;
	});
	checkActivity(1800000, 60000, 0); // timeout = 30 minutes, interval = 1
										// minute.
});

function checkActivity(timeout, interval, elapsed) {
	if ($.active) {
		elapsed = 0;
		$.active = false;
	}
	if (elapsed < timeout) {
		elapsed += interval;
		setTimeout(function() {
			checkActivity(timeout, interval, elapsed);
		}, interval);
	} else {
		window.location = '/enma/logout'; // Redirect to "session
														// expired" page.
	}
}